﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KingerRobot.MexicoSailunWMS.SpiService;


public class BPDAManagerServiceImpl : IPDAManagerService
{
    private readonly static ITask _Task = new BTask();
    private readonly static ITaskCmd _TaskCmd = new BTaskCmd();
    private readonly static IRcsEquip _RcsEquip = new BRcsEquip();
    private readonly static IWmsOutOrderMaster _WmsOutOrderMaster = new BWmsOutOrderMaster();
    private readonly static IWmsOutOrderSummary _WmsOutOrderSummary = new BWmsOutOrderSummary();
    private readonly static IRcsLocation _RcsLocation = new BRcsLocation();
    private readonly static IWcsEquipLoc _WcsEquipLoc = new BWcsEquipLoc();
    private readonly static IWcsLocSku _WcsLocSku = new BWcsLocSku();
    private readonly static ICuringManageService _CuringManageService = new BCuringManageImpl();
    private readonly static IWcsAsrsNetOutPut _WcsAsrsNetOutPut = new BWcsAsrsNetOutPut();
    private readonly static IWcsNetInCuring _WcsNetInCuring = new BWcsNetInCuring();
    private readonly static IBakWcsTask _BakWcsTask = new BBakWcsTask();
    private readonly static IProdProduct _ProdProduct = new BProdProduct();
    private readonly static IWcsAsrsCrnAbnormalInput _WcsAsrsCrnAbnormalInput = new BWcsAsrsCrnAbnormalInput();



    public TaskBean? GetTask(string code)
    {
        var taskList = _Task.GetVTasks().Where(t => t.ProductCode == code).ToList();
        var _ret = taskList.Select(f => new TaskBean
        {
            cmdExcuteTime=f.CmdExcuteTime,
            cmdTime = f.CmdTime.GetValueOrDefault(),
            createTime = f.createTime.GetValueOrDefault(),
            CurrentLoc = f.CurrentLoc,
            StartEquip = f.StartEquip,
            StartLoc = f.StartLoc,
            TargetLoc = f.TargetLoc,
            TaskNo = f.TaskNo.GetValueOrDefault(),
            TaskStatus = f.TaskStatus.GetValueOrDefault(),
            TaskType = f.TaskType.GetValueOrDefault(),
            CurrentEquip = f.CurrentEquip,
            ProductCode = f.ProductCode,
            MaterialCode = f.MaterialCode,
            MaterialHeight = f.MaterialHeight.GetValueOrDefault(),
            TaskTypeDesc = EnumExtension.GetDescription((EnumTaskType)Enum.Parse(typeof(EnumTaskType), f.TaskType.ToString())),
            TaskStatusDesc = EnumExtension.GetDescription((EnumTaskStatus)Enum.Parse(typeof(EnumTaskStatus), f.TaskStatus.ToString())),
        }).FirstOrDefault();





        return _ret;
    }

}